#ifndef ODBC_ENVIRONMENT_HPP
#define ODBC_ENVIRONMENT_HPP

#include "odbc/odbc_config.hpp"
#include "odbc/details/os_sql_wrapper.hpp"

namespace odbc
{

/// \ingroup OdbcLibrary
/// \brief It encapsulates the odbc environment object, used to open connections to databases.
class ODBC_DECL environment
{
public:
	
	/// \brief Initializes the environment object using the specified version number of the odbc system, by allocating 
	///	the odbc environment handle.
	/// \param version the version number of the odbc system.
	environment( unsigned int version);

	/// \brief It deallocates the odbc environment handle.
	~environment() throw();

	/// \brief It gets the version of the used ODBC environment.
	/// \return the odbc version used.
	unsigned int version() const 
	{ 
		return version_; 
	}

private:
	/// \internal
	/// \brief Stores the odbc handle to odbc environment.
	SQLHANDLE handle_;

	/// \internal
	/// \brief Stores the odbc version used.
	unsigned int version_;

private:
	/// \internal
	/// The class \c connection is declared as friend to \c environment class, in order to allow it to access 
	///	the \c handle private data member without exposing it to the other classes in the library or outside the 
	///	library.
	friend class connection;

	/// \internal
	/// The class \c odbc_error is declared as a friend to \c environment class, in order to allow it to access the 
	///	\c handle private data member without exposing it to the other classes in the library or outside the library.
	friend class odbc_error;

	environment( const environment& );
	environment& operator=( const environment& );
};

} // namespace odbc

#endif // ODBC_ENVIRONMENT_HPP
